<template>
	<view>
		<!-- 公司信息 -->
		<uni-nav-bar  :border="false">
			<block slot="left">
				<!-- <image class="back-img" src="../../../static/index.jpg" mode="widthFix" @click="go_back()"></image> -->
				<!-- 	<image class="right-img" src="../../../static/add.png" mode="" @click="toAdd()"></image> -->
			</block>
		</uni-nav-bar>
		<view class="company_info">
			<mescroll-uni refs="mescroll" @getData="getData">
				<block slot="list">
					<block v-if="dataList.length">
						<view class="company_info-base ns-border-color-gray" v-for="(item,index) in dataList" :key="index">
							<view class="img">
								<image :src="item.headimg ? $util.img(item.headimg) : $util.getDefaultImage().default_headimg" mode="aspectFit"></image>
							</view>
							<view class="flex">
								<view class="company_name ns-font-size-lg">
									<view class="t1">{{item.username}}</view>
									<view class="t2 ns-text-color-gray">{{item.company_name}}<text v-if="item.invite_name" class="tips">({{item.invite_name}}邀请)</text></view>
								</view>
								<view class="time ns-font-size-sm ns-text-color-gray-lighten">{{ $util.timeStampTurnTime(item.reg_time).toString().substring(0,11)}}</view>
							</view>
						</view>
					</block>
					<block v-else>
						<ns-empty text="暂无数据" :isIndex="!1"></ns-empty>
					</block>
				</block>

			</mescroll-uni>
			<!-- #ifdef MP -->
			<view class="confirm-btn" @click="addFun">
				<view>添加</view>
			</view>
			<!-- #endif -->

		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList: [],
				//假数据
				jiaData: [
				{
					company_name: "dsqwq",
					headimg: "",
					invite_id: 106,
					member_id: 130,
					member_level_name: "企业用户等级一",
					mobile: "13201236548",
					reg_time: 1609151502,
					username: "132343",
				},
				{
					company_name: "dsqwq",
					headimg: "",
					invite_id: 106,
					invite_name: '子企业邀请的哦',
					member_id: 130,
					member_level_name: "企业用户等级一",
					mobile: "13201236548",
					reg_time: 1609151502,
					username: "132343",
				},
				{
					"username": "user4",
					"mobile": "",
					"reg_time": 1608278091,
					"member_id": 27,
					"member_level_name": "企业用户等级一"
				}, {
					"username": "user2",
					"mobile": "",
					"reg_time": 1608277784,
					"member_id": 62,
					"member_level_name": "企业用户等级一"
				}, {
					"username": "user31",
					"mobile": "",
					"reg_time": 1608277785,
					"member_id": 46,
					"member_level_name": "企业用户等级一"
				},{
					"username": "user334",
					"mobile": "",
					"reg_time": 1608277786,
					"member_id": 262,
					"member_level_name": "企业用户等级一"
				},{
					"username": "user3213",
					"mobile": "",
					"reg_time": 1608277787,
					"member_id": 25,
					"member_level_name": "企业用户等级一"
				},{
					"username": "user33214",
					"mobile": "",
					"reg_time": 1608277788,
					"member_id": 26,
					"member_level_name": "企业用户等级一"
				},{
					"username": "user3213",
					"mobile": "",
					"reg_time": 1608277789,
					"member_id": 23,
					"member_level_name": "企业用户等级一"
				},{
					"username": "user233",
					"mobile": "",
					"reg_time": 1608277794,
					"member_id": 56,
					"member_level_name": "企业用户等级一"
				},{
					"username": "user43",
					"mobile": "",
					"reg_time": 1608277714,
					"member_id": 16,
					"member_level_name": "企业用户等级一"
				},{
					"username": "user12323",
					"mobile": "",
					"reg_time": 1608277284,
					"member_id": 26,
					"member_level_name": "企业用户等级一"
				},{
					"username": "2324334",
					"mobile": "15632598551",
					"reg_time": 1608113690,
					"member_id": 19,
					"member_level_name": "企业权益等级二"
				}],
				mescroll: null
			};
		},
		onShow() {
			// this.teamOrganizationAndMember = uni.getStorageSync('teamOrganizationAndMember')
			// console.log(this.teamOrganizationAndMember)
		},
		// onNavigationBarButtonTap() {
		// 	this.$util.allowAddGo('ADDON_YUNCHUANG_AGENT_MEMBER_INVITE','/otherpages/agent/my_member_edit/my_member_edit');
		// },
		onLoad(option) {},
		methods: {
			// toDetail(e) {
			// 	//console.log(e);
			// 	this.$util.redirectTo("/otherpages/member/bussiness_user/add?member_id=" + e);
			// },
			//添加用户
			toAdd() {
				this.$util.redirectTo("/otherpages/member/bussiness_user/add");
			},
			go_back() {
				uni.navigateBack({
					url: '/pages/member/index/index',
				})
			},
			getData(mescroll) {
				this.mescroll = mescroll;
				this.$api.sendRequest({
					url: '/api/member/getChildEnterpriseUserList',
					data: {
						page_size: mescroll.size,
						page: mescroll.num
					},
					success: res => {
						let newArr = []
		
						let msg = res.message;
						if (res.code == 0 && res.data) {
							newArr = res.data.list;
						} else {
							this.$util.showToast({
								title: msg
							})
						}
						mescroll.endSuccess(newArr.length);
						//设置列表数据
						if (mescroll.num == 1) this.dataList = []; //如果是第一页需手动制空列表
						this.dataList = this.dataList.concat(newArr); //追加新数据
						if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
					},
					fail: res => {
						mescroll.endErr();
						if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
					}
				});
			}
		}
	};
</script>

<style lang="scss">
	@import '@/otherpages/member/bussiness_user/public/css/classification.scss';

	/deep/.mescroll-uni-fixed {
		position: relative;
		top: 0 !important;
		height: 100% !important;
	}

	.back-img {
		width: 20rpx;
		height: 20rpx;
		margin-left: 20rpx;
	}

	.right-img {
		position: absolute;
		width: 35rpx;
		height: 35rpx;
		right: 30rpx;
		top: 30rpx;
	}

	.tips {
		color: red;
	}

	/* #ifdef MP */
	.confirm-btn {
		width: 100%;
		height: 144rpx;
		background-color: #fff;

		view {
			width: 90%;
			height: 80rpx;
			border-radius: $ns-border-radius;
			background-color: #ff464a;
			line-height: 80rpx;
			color: #fff;
			text-align: center;
			margin-top: 20rpx;
		}

		display: flex;
		z-index: 8;
		justify-content: center;
		position: fixed;
		bottom: 0;
	}

	.btn-zw-bar {
		height: 144rpx;
	}

	/* #endif */

	.company_info {
		height: calc(100vh - 44px - 60rpx);

		.company_info-base {
			padding-right: 0;
			padding-left: 0;
			margin-left: 30rpx;
			border-bottom: 1px solid;

			.flex {
				position: relative;
				flex: 1;
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding-right: 30rpx;
			}

			.flex::after {
				content: '';
				position: absolute;
				border-bottom: 1px solid #eee;
				width: 100%;
				bottom: -36rpx;
			}

			.flex:last-child::after {
				border-bottom: 0;
			}

			.img {
				height: 90rpx;
				width: 90rpx;
			}
		}
	}

	.flex-list .flex-item .flex-right .flex-text .iconfont {
		font-weight: bold;
	}

	.company_info .company_info-base .img {
		width: 80rpx;
		height: 80rpx
	}

	.time {
		align-self: flex-start;
		height: 50rpx;
		line-height: 50rpx;
		color: #8F95AD
	}
</style>
